export class NumFactory {

    static generate = (s: string): string => {
        return `${s}${NumFactory.formatTime(new Date())}`;
    };

    // 时间格式化
    private static formatTime = date => {
        const year = date.getFullYear();
        const month = date.getMonth() + 1;
        const day = date.getDate();
        const hour = date.getHours();
        const minute = date.getMinutes();
        const second = date.getSeconds();
        return [year, month, day, hour, minute, second].map(NumFactory.formatNumber).join('');
        // return [year, month, day].map(NumFactory.formatNumber).join('-') + ' ' + [hour, minute, second].map(NumFactory.formatNumber).join(':')
    };

    private static formatNumber = n => {
        n = n.toString();
        return n[1] ? n : '0' + n;
    };

}
